package com.xn.app.muying.adpter;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.xn.app.muying.R;
import com.xn.app.muying.bean.ChanJianListBean;

import java.util.ArrayList;

/**
 * 孕期检查适配器
 * Created by Administrator on 2016/10/29.
 */
public class ChanJianListAdapter extends BaseAdapter {

    private LayoutInflater inflater;
    private Context context;
    private ArrayList<ChanJianListBean> list = new ArrayList<ChanJianListBean>();
    int number=0;

    public ChanJianListAdapter(Context context, ArrayList list) {
        this.context = context;
        this.list = list;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        number=i;
        ViewHolder viewHolder=null;
        if (view == null) {
            viewHolder = new ViewHolder();
            view = inflater.inflate(R.layout.item_gridview_check, null);
            viewHolder.title = (TextView) view.findViewById(R.id.title);
            viewHolder.keypoint= (TextView) view.findViewById(R.id.keypoint);
            viewHolder.tv_order= (TextView) view.findViewById(R.id.activity_chanjian_order);
            viewHolder.tv_must = (TextView) view.findViewById(R.id.activity_chanjian_must);
            view.setTag(viewHolder);
        }  else {
        viewHolder = (ViewHolder) view.getTag();
    }
        viewHolder.title.setText(list.get(i).getTitle());
        viewHolder.keypoint.setText(list.get(i).getKeyPoint());
        viewHolder.tv_order.setText("孕"+list.get(i).getStartWeek()+"周一一"+list.get(i).getEndWeek()+"周");
        viewHolder.tv_must.setText(list.get(i).getRequiredItemsName());
        return view;
    }


    class ViewHolder {
        TextView title;
        TextView tv_order;
        TextView tv_must;
        TextView keypoint;
    }
}
